import { app, Menu, Tray } from 'electron'
import path from 'path'

let tray = null
const iconPath = path.join(
  `${__dirname}/../src/assets`,
  'logo.png',
)

const handleItem = (menuItem, browserWindow, event) => {
  console.log('我点击了系统菜单栏', menuItem, browserWindow, event);
}

export const initTray = () => {
  tray = new Tray(iconPath)
  const contextMenu = Menu.buildFromTemplate([
    { label: 'Item1', type: 'radio' },
    { label: 'Item2', click: handleItem },
    { label: 'Item2', click: handleItem },
  ])
  tray.setToolTip('app')
  tray.setContextMenu(contextMenu)

  tray.on('click', (e, bounds) => {
    console.log('click', e, bounds);
  })
}



